﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="VMIsikutToendavDokumentResponse", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(VMIsikutToendavDokumentResponse))]
    public class VMIsikutToendavDokumentResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IVMIsikutToendavDokumentResponse clazz;
        
        public VMIsikutToendavDokumentResponseSerializer(IVMIsikutToendavDokumentResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("VastuseTekst");
            if (clazz.VastuseTekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VastuseTekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VastuseTekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veakood");
            if (clazz.Veakood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veakood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veakood");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="VastuseTekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>VMIsikutToendavDokumentResponse>VastuseTekst");
                }
                clazz.VastuseTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("VastuseTekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>VMIsikutToendavDokumentResponse>VastuseTekst", Reader.LocalName);
            }
            if (Reader.LocalName=="Veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>VMIsikutToendavDokumentResponse>Veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>VMIsikutToendavDokumentResponse>Veakood", Reader.LocalName);
            }
        }
    }
}
